#include "head.h"
/* Usage:  */
FILE* file;
int get_key_value(const char*key,char*key_value)
{
  while(1)
  {
      char line[100];
      memset(line,0,sizeof(line));
      char*res=fgets(line,sizeof(line),file);
      if(res==NULL)
      {
          printf("error:do not get data\n");
          return -1;
      }
      char*line_key=strtok(line,"=");
      if(strcmp(line_key,key)==0)
      {
        char*line_value= strtok(NULL,"=");
        strcpy(key_value,line_value);
        return 0;
      }
  }

}
int read_config(const char*file_name,char*port,char*ip){                                  

    file=fopen(file_name,"r");
    get_key_value("port",port);
    printf("port:%s\n",port);
    get_key_value("ip",ip);
    printf("ip:%s\n",ip);
    fclose(file);
    return 0;
}

